package pkg;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

public class LoginAction extends Action {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		HttpSession session=request.getSession();
		DynaActionForm myForm=(DynaActionForm)form;
		String submit=myForm.getString("submit");
		String path="error";
		System.out.println(submit);
		if(submit.equals("Register Account"))
//			session.invalidate();
			path="register";
		if(submit.equals("Forgot Password"))
			path="forgot";
		if(submit.equals("Sign Out")){
			session.invalidate();
			path="home";
		}
		if(submit.equals("Back Home")){
			path="home";
		}
			return mapping.findForward(path);
	}

}
